package com.njwb.thread;


/**
 * Description: 类的描述
 * Author: yuandeyin@itany.com
 * Date: 2025-08-06 16:18
 * Version: 1.0
 */
public class TestPriority {
    public static void main(String[] args) {
        PriorityOne priorityOne = new PriorityOne();
        PriorityTwo priorityTwo = new PriorityTwo();
        Thread t1 = new Thread(priorityOne);
        Thread t2 = new Thread(priorityTwo);
        t1.setName("priorityOne线程");
        t2.setName("priorityTwo线程");
        t1.setPriority(Thread.MAX_PRIORITY);
        t2.setPriority(Thread.MIN_PRIORITY);

        t1.start();
        t2.start();

    }
}

class PriorityOne implements Runnable{

    @Override
    public void run() {
      for(int i = 0; i < 10 ;i++){
          try {
              Thread.sleep(500);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
          System.out.println(Thread.currentThread().getName() + "--->" + i);
      }
    }
}

class PriorityTwo implements Runnable{

    @Override
    public void run() {
        for(int i = 0; i < 10 ;i++){
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "--->" + i);
        }
    }
}

